<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function selectAll()
			{
				var cbs = document.querySelectorAll("input[type=checkbox]")
				
				for(var i in cbs)
				{
					cbs[i].checked = "checked";
				}
			}
			
			function selectNone()
			{
				var cbs = document.querySelectorAll("input[type=checkbox]")
				
				for(var i in cbs)
				{
					cbs[i].checked = "";
				}
			}
			
			function selectOther()
			{
				var cbs = document.querySelectorAll("input[type=checkbox]")
				
				for(var i in cbs)
				{
					cbs[i].checked = !cbs[i].checked;
				}
			}
		</script>
	</head>
	<body>
		<input type="button" value="全选" onclick="selectAll()" />
		<input type="button" value="全不选" onclick="selectNone()" />
		<input type="button" value="反选" onclick="selectOther()" />
		<table border="1">
			<tr>
				<td></td>
				<td>编号</td>
				<td>姓名</td>
				<td>年龄</td>
			</tr>
			<tr>
				<td><input type="checkbox" checked="checked"/> </td>
				<td>1</td>
				<td>张三</td>
				<td>18</td>
			</tr>
			<tr>
				<td><input type="checkbox" /></td>
				<td>2</td>
				<td>李四</td>
				<td>18</td>
			</tr>
			<tr>
				<td><input type="checkbox" /></td>
				<td>3</td>
				<td>王五</td>
				<td>18</td>
			</tr>

		</table>
	</body>
</html>